package com.nbjtjc.safe.mapper.safe;

import com.nbjtjc.safe.model.safe.SafeDangerInspectTask;
import com.nbjtjc.util.MyMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SafeDangerInspectTaskMapper extends MyMapper<SafeDangerInspectTask> {
    public List<SafeDangerInspectTask> search(@Param("task") SafeDangerInspectTask task);
    int searchCount(@Param("task") SafeDangerInspectTask task);
    @Update("update safe_danger_inspect_task set danger_counter=#{dc} , inspect_counter =#{ic},task_status=1  " +
            " where id=#{ti}")
    public int updateDangerCount(@Param("dc") int dangerCount,
                                 @Param("ic") int inspectCount,
                                 @Param("ti") int taskId);

    @Select("select * from safe_danger_inspect_task where inspect_plan_id=#{planId} order by id desc limit 1 ")
    public SafeDangerInspectTask latestTask(@Param("planId") int planId);

    @Delete("delete from safe_danger_inspect_task where inspect_plan_id=#{planId}")
    int deleteByPlanId(@Param("planId") int planId);


    @Select("select id from safe_danger_inspect_task where inspect_plan_id=#{planId}")
    List<Integer> selectIdsByPlanId(@Param("planId") int planId);
}